package com.atguigu.jdbc;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;

public class PropertiesDemo2 {

    @Test
    public void test() throws IOException {
        Properties p = new Properties();
        FileInputStream fis = new FileInputStream("jdbc.properties");
        p.load(fis);
        String username = p.getProperty("username");
        String password = p.getProperty("password");
        String url = p.getProperty("url");
        System.out.println(username);
        System.out.println(password);
        System.out.println(url);
    }
    @Test
    public void test1() throws IOException {
        Properties p = new Properties();
        p.load(this.getClass().getClassLoader().getResourceAsStream("jdbc.properties"));
        String username = p.getProperty("username");
        System.out.println(username);
    }
}
